package com.controller.library;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.library.Course;
import com.bean.library.Paper;

public class GetSumilatePaperListServlet extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public void doGet(HttpServletRequest request,HttpServletResponse response){
		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int pageNum = Integer.parseInt(request.getParameter("submit_page_num"));
		//int curPageNum = Integer.parseInt(request.getParameter("page_num"));
		Course course = (Course)request.getSession().getAttribute("selectedCourse");
		ArrayList<Paper> partialPaperList = course.getBriefPaperList((pageNum - 1)*5, 5);
		request.getSession().setAttribute("partialPaperList", partialPaperList);
		course.setStartIndex(pageNum - 1);
		request.getSession().setAttribute("selectedCourse",course);
		try{		
			response.sendRedirect("/Exam1/student/page/simulate.jsp?"+request.getQueryString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
